#include <iostream>
using namespace std;
int b[100005];
int main()
{
    int n; //n层
    int m; // m个区间
    cin >> n >> m;

    while (m--)
    {
        int l, r, value;
        cin >> l >> r >> value;
        b[l+1] += value;
        b[r + 1+1] -= value;
    }
    for (int i = 1; i <= n; i++)
        b[i] = b[i] + b[i - 1];
    int sum = 0;
    for (int i = 1; i <= n; i++)
        sum += b[i];
    /*
    也可以一次性搞定
    int sum=b[1];
    for(int i=1; i<=n; i++){
    b[i]=b[i]+b[i-1];
    sum+=b[i]
    }
    */
    cout << sum << endl;
}